package com.lujianfei.netease_android_mvvm.module;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import com.lujianfei.netease_android_mvvm.R;
import com.lujianfei.netease_android_mvvm.databinding.ActivityMainBinding;
import com.lujianfei.netease_android_mvvm.main.IMainMvvm;
import com.lujianfei.netease_android_mvvm.main.impl.MainViewModel;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProviders;
import dagger.Module;
import dagger.Provides;

@Module
public class MainActivityModule {

    private AppCompatActivity context;

    public MainActivityModule(AppCompatActivity context) {
        this.context = context;
    }

    @Provides
    public MainViewModel provideViewModel() {
        MainViewModel mainViewModel = ViewModelProviders.of(context).get(MainViewModel.class);
        return mainViewModel;
    }

    @Provides
    public ActivityMainBinding provideActivityMainBinding() {
        return DataBindingUtil.setContentView(context, R.layout.activity_main);
    }

    @Provides
    public View provideActionBarView(){
        return LayoutInflater.from(context).inflate(R.layout.actionbar_layout, null);
    }
}
